package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.RequisitionProduct;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class RequisitionProductVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "请购单id")
    private Integer requisitionId;

    @ApiModelProperty(value = "物品SPU_id")
    private Integer productSpuId;

    @ApiModelProperty(value = "购买数量")
    private Double productBuyNum;

    @ApiModelProperty(value = "单位id")
    private Integer unitId;

    @ApiModelProperty(value = "单价")
    private Double price;

    @ApiModelProperty(value = "总金额")
    private Double productBuyPrice;

    @ApiModelProperty(value = "物品生单状态：1未生单2已生单")
    private Integer productState;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static RequisitionProduct convert(RequisitionProductVO vo) {
        RequisitionProduct entity = new RequisitionProduct();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<RequisitionProduct> convertList(List<RequisitionProductVO> list) {
        List<RequisitionProduct> resultList = new ArrayList<>();
        for (RequisitionProductVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
